package com.jk.service.impl;
import com.github.pagehelper.PageHelper;
import com.jk.bean.Author;
import com.jk.bean.Page;
import com.jk.bean.PingLun;
import com.jk.bean.SendPage;
import com.jk.mapper.CommentMapper;
import com.jk.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Resource
    private CommentMapper commentMapper;

    @Override
    public SendPage getPingLun(Page pag, PingLun pl) {
        List<PingLun> ll=commentMapper.getPingLun(pl);
        PageHelper.startPage(pag.getPage(),pag.getRows());
        List<PingLun> aa=commentMapper.getPingLun(pl);

        SendPage sendPage = new SendPage(ll.size(), aa);

        return sendPage;
    }

    @Override
    public void delPingLun(String id) {
        commentMapper.delPingLun(id);
    }

    @Override
    public PingLun updaPingLun(String id) {

        return commentMapper.updaPingLun(id);
    }

    @Override
    public void addPingLun(PingLun p) {
        if(p.getId()!=null){
            commentMapper.uptadePingLun(p);
        }

            commentMapper.addPingLun(p);
    }

    @Override
    public List<Author> getAuthor() {

        return commentMapper.getAuthor();
    }


}
